<template lang="html">
  <div class="container content content-wage" v-loading="loading">
    <!-- <div class="content-wage-search"> 
      <el-form :inline="true"  class="demo-form-inline">
            <el-form-item>
                <el-button type="primary" @click.stop="addGroups">新增会议</el-button>
            </el-form-item>
          </el-form>
    </div> -->

    <div class="wage-add">
    <el-button type="primary" @click.stop="addFiles">添加文件</el-button>
      <el-table :data="blocks" style="width: 100%" class="wage-table">
        <el-table-column prop="startTime" label="开始时间" width="100">
        </el-table-column>
        <el-table-column prop="createTIme" label="完成时间" width="100">
        </el-table-column>
        <el-table-column prop="dataDate" label="上报日期" width="120">
        </el-table-column>
        <el-table-column prop="package1162" label="数据包名" width="200">  
        </el-table-column>
        <!-- <el-table-column prop="msg1162" label="数据包上传状态" width="170">  
        </el-table-column> -->
        <el-table-column prop="package1168" label="附件Db包名" width="200">  
        </el-table-column>
        <el-table-column prop="packageFile1168" label="附件包名" width="200">  
        </el-table-column>
        <!-- <el-table-column prop="msg1162" label="附件包上传状态" width="170">  
        </el-table-column> -->
        <el-table-column  label="状态" width="100">
          <template slot-scope="scope">
            <p>{{scope.row.status === 1 ? '成功' : '失败'}}</p>
           </template>
        </el-table-column>
        <el-table-column prop="msg" label="上传状态" width="170">  
        </el-table-column>
      </el-table>

      <div class="wage-add-pagination">
        <el-pagination
          background
          layout="prev, pager, next"
          :current-page.sync="page"
          :page-size="pageSize"
          @current-change="loadMeetingList"
          :total="total"
        >
        </el-pagination>
      </div>

    <el-dialog title="文件上传" :visible.sync="dialogTableVisible">
        <file-add
        v-if="dialogTableVisible"
        @hascreated="hascreated"
        @cancelAdd="cancelAddFun"
      >
      </file-add>
    </el-dialog>

    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import axios from 'axios';
import storage from '@/assets/js/storage';
import {  createConfig } from '@/assets/js/tools';
import FileAdd from '@/components/gzw/FileAdd'
//import util from '@/assets/js/util';
export default {
  name: 'lanlinNews',
  data() {
    return {
      loading: false,
      page: 1,
      pageSize: 10,
      total: 0,
      blocks: [],
      dialogTableVisible: false
    };
  },
  components: {
    FileAdd
  },
  computed: {
    ...mapGetters({
      userInfo: 'getUserInfo',
    }),
    titleName() {
      return this.type === 'add' ? '新增版块' : '编辑版块';
    },
  },
  methods: {
    hascreated() {
      this.dialogTableVisible = false;
      this.loadMeetingList();
    },
    cancelAddFun() {
      this.dialogTableVisible = false;
      this.pdfVisible = false;
    },
    addFiles() {
      this.type = 'add';
      this.dialogTableVisible = true;
    },
    loadMeetingList() {
      this.loading = true;
      let param = {
        page: this.page - 1,
        pageSize: this.pageSize
      };
      let path = '/station/api/shangbao/page?vs=' + Date.now();
      let config = createConfig(this.userInfo.token);
      axios
        .post(path, param, config)
        .then((data) => {
          if (data.data.status === 'SUCCESS') {
            let content = data.data.content;
            if (content && content.content && Array.isArray(content.content)) {
              this.blocks = content.content;
              this.total = content.totalElements;
            }
          } else {
            this.$message.error(
              data.data.errorMsg ? data.data.errorMsg : '获取上传列表出错'
            );
            if("10010"===data.data.errorCode){
                this.$router.replace({ path: '/' })
            }
          }
          this.loading = false;
        })
        .catch((err) => {
          // eslint-disable-next-line no-console
          console.log(err);
          this.$message.error('获取上传列表出错');
          this.loading = false;
        });
    },
    gotoFile(meeting) {
      let param = { id: meeting.id, subject:meeting.subject};
      this.$router.push({
        path: "meetingFile",
        query: param
      });
    }
    

  },
  mounted() {
    storage.initUserInfo();
    this.loadMeetingList();
  },
};
</script>

<style lang="scss" scoped>
.content-wage {
  padding: 90px 30px 30px 30px !important;
  .wage-menu {
    margin-bottom: 30px;
  }
  .wage-table {
    margin-top: 25px;
  }
  .wage-add-pagination {
    margin-top: 20px;
  }
}
</style>
